import 'dart:math';

import 'package:flutter/material.dart';

void main() {
  runApp(new MaterialApp(
    home: Scaffold(
      appBar: AppBar(
        title: Text("下拉刷新refreshindicator"),
      ),
      body: HomeScreen(),
    ),
  ));
}

class HomeScreen extends StatefulWidget {
  @override
  _HomeScreenState createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: <Widget>[
        RefreshIndicator(
            child: ListView(
              children: <Widget>[
                Container(height: 100.0,
                color: Colors.red,)
              ],
            ),
            onRefresh: () async {
              // onRefresh必须是async  + await
              await Future.delayed(new Duration(seconds: 3));
            }),
      ],
    );
  }
}
